package games.flvPlayer.data
{
	import core.Global;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import interfaces.IAction;
	
	public class LoadedProgress extends EventDispatcher implements IAction
	{
		private var m_start:Boolean;
		private var m_pause:Boolean;
		
		private var m_stream:StreamManager;
		private var m_value:Number;
		
		public function LoadedProgress(sm:StreamManager)
		{
			m_stream = sm;
			m_stream.addEventListener(StreamManager.GET_METADATA,onGetTime);
		}
		
		public function set start(b:Boolean):void
		{
			m_start = b;
		}
		
		public function get start():Boolean
		{
			return m_start;
		}
		
		public function set pause(b:Boolean):void
		{
		}
		
		public function get pause():Boolean
		{
			return false;
		}
		
		public function update(t:Object=null):void
		{
			
			m_value = m_stream.stream.bytesLoaded / m_stream.stream.bytesTotal;
			dispatchEvent(new Event(Event.CHANGE));
		}
		
		public function get value():Number
		{
			return m_value;
		}
		
		private function onGetTime(e:Event):void
		{
			Global.addAction(this);
		}
	}
}